// pages/hotel/index.js
const App = getApp()
const chooseLocation = requirePlugin('chooseLocation');
Page({
  data: {
    top:0,
    num:0,
    date: '2020-09-01',
    enddate: '2020-09-10',
    activeArr:[{id:"1",name:"商务"},{id:"2",name:"婚礼"}],
    array: [{id:"aa",name:"111"},{id:"aa",name:"222"},{id:"aa",name:"333"}],
    location:{name: ""},
    demandType:'1',
    transactionType:'1',
    transactionArr:[{id:"1",name:"化妆师"},{id:"2",name:"摄像师"},{id:"3",name:"主持人"}],
    demandPriceArr:[{id:"1",name:"3000以下"},{id:"2",name:"3千到5千"},{id:"3",name:"5千到8千"},{id:"4",name:"8千到1.2万"},{id:"5",name:"1.2万到1.5万"},
    {id:"6",name:"1.5万到2万"},{id:"7",name:"2万以上"}],
    demandPrice:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let top = 58+App.globalData.systemInfo.statusBarHeight + App.globalData.menuButton.height + (App.globalData.menuButton.top - App.globalData.systemInfo.statusBarHeight)*2
    console.log(top)
    this.setData({top:top})
  },
  pushInfo(){
    wx.navigateTo({
      url: '../pay/index',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const location = chooseLocation.getLocation();
    if(location){
      this.setData({location})
    }
  },
  change(e){
    console.log(e.detail)
  },
  activeChange(e){
    this.setData({
      demandType:this.data.activeArr[e.detail].id
    })
  },
  transactionChange(e){
    this.setData({
      transactionType:this.data.transactionArr[e.detail].id
    })
  },
  demandPriceChange(e){
    this.setData({
      demandPrice:this.data.demandPriceArr[e.detail].name
    })
  },
  
  bindDateChange: function(e) {
    this.setData({
      date: e.detail.value
    })
  },
  endChange: function(e) {
    this.setData({
      enddate: e.detail.value
    })
  },
  lenChange(e){
    console.log(e)
    let value = e.detail.value;
    this.setData({num:value.length})
  },
  tohotelDetail(){
    wx.navigateTo({
      url: '../hotelDetail/index',
    })
  },
  goGetLocation(){
    const key = 'N4PBZ-G2UWQ-X545S-GES3K-HS7J5-RXBNX'; //使用在腾讯位置服务申请的key
    const referer = '金刚统筹-用户端'; //调用插件的app的名称
    const category = '饭店,酒店酒楼';
    wx.navigateTo({
      url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&category=${category}`
    });
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})